package com.exam.service;

import com.exam.dao.QuestionCustDao;
import com.exam.dao.QuestionDao;
import com.exam.entity.Question;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class QuestionService {

    @Autowired
    QuestionDao questionDao;

    @Autowired
    QuestionCustDao questionCustDao;

    public int add(Question question){
        return questionDao.insert(question);
    }

    public List<Question> getByQuery(Integer subject){
        return questionCustDao.getListByQuery(subject);
    }

    public void delete(Long questionid){
        questionDao.deleteByPrimaryKey(questionid);
    }

    public void update(Question question){

        //全量更新
        //questionDao.updateByPrimaryKey(question);
        //非空更新
        questionDao.updateByPrimaryKeySelective(question);
    }

    public Question getById(Long questionid){
        return questionDao.selectByPrimaryKey(questionid);
    }

}
